(function() {
	$('#success').hide();
	$('#error').hide();
    var userName=$.cookie.getCookieValue('userName');
    var password=$.cookie.getCookieValue('password');
    $('#userName').val(userName);
    $('#password').val(password);

	loginData={};
	loginData.login=function(){
		userName=$('#userName').val();
		password=$('#password').val();
		var isChecked=$('#isRecord')[0].checked;
		if(!!isChecked){
				$.cookie.setCookie("userName",userName,24,"/");  
                $.cookie.setCookie("password",password,24,"/"); 
		}
        $.post('loginData',{userName:userName,password:password,isChecked:isChecked},function(data){
            if(data.status==1){
            	$('#success').text('登录成功！').show();
            	setTimeout(function(){
            		window.location.href=data.data;
            	},200);
            	
            }else{
            	$('#error').text('用户名或密码不正确！').show();
            }
        },'JSON');
	}
	$.bindData.compileAll($('#login'),loginData);

})()